home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Dialogs.h < prev    next >
Text File  |  1995-07-06  |  15KB  |  410 lines

  1. /*
  2.      File:        Dialogs.h
  3.  
  4.      Contains:    Dialog Manager interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __DIALOGS__
  21. #define __DIALOGS__
  22.  
  23.  
  24. #ifndef __ERRORS__
  25. #include <Errors.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MEMORY__
  30. #include <Memory.h>
  31. #endif
  32. /*    #include <Types.h>                                            */
  33. /*    #include <MixedMode.h>                                        */
  34.  
  35. #ifndef __MENUS__
  36. #include <Menus.h>
  37. #endif
  38. /*    #include <Quickdraw.h>                                        */
  39. /*        #include <QuickdrawText.h>                                */
  40.  
  41. #ifndef __CONTROLS__
  42. #include <Controls.h>
  43. #endif
  44.  
  45. #ifndef __WINDOWS__
  46. #include <Windows.h>
  47. #endif
  48. /*    #include <Events.h>                                            */
  49. /*        #include <OSUtils.h>                                    */
  50.  
  51. #ifndef __TEXTEDIT__
  52. #include <TextEdit.h>
  53. #endif
  54.  
  55. #ifndef __EVENTS__
  56. #include <Events.h>
  57. #endif
  58.  
  59. #ifdef __cplusplus
  60. extern "C" {
  61. #endif
  62.  
  63. #if PRAGMA_ALIGN_SUPPORTED
  64. #pragma options align=mac68k
  65. #endif
  66.  
  67. #if PRAGMA_IMPORT_SUPPORTED
  68. #pragma import on
  69. #endif
  70.  
  71.  
  72. enum {
  73.     ctrlItem                    = 4,
  74.     btnCtrl                        = 0,
  75.     chkCtrl                        = 1,
  76.     radCtrl                        = 2,
  77.     resCtrl                        = 3,
  78.     statText                    = 8,
  79.     editText                    = 16,
  80.     iconItem                    = 32,
  81.     picItem                        = 64,
  82.     userItem                    = 0,
  83.     itemDisable                    = 128,
  84.     ok                            = 1,
  85.     cancel                        = 2,
  86.     stopIcon                    = 0,
  87.     noteIcon                    = 1,
  88.     cautionIcon                    = 2
  89. };
  90.  
  91. /* new, more standard names for dialog item constants */
  92. enum {
  93.     kControlDialogItem            = ctrlItem,
  94.     kButtonDialogItem            = ctrlItem + btnCtrl,
  95.     kCheckBoxDialogItem            = ctrlItem + chkCtrl,
  96.     kRadioButtonDialogItem        = ctrlItem + radCtrl,
  97.     kResourceControlDialogItem    = ctrlItem + resCtrl,
  98.     kStaticTextDialogItem        = statText,
  99.     kEditTextDialogItem            = editText,
  100.     kIconDialogItem                = iconItem,
  101.     kPictureDialogItem            = picItem,
  102.     kUserDialogItem                = userItem,
  103.     kItemDisableBit                = itemDisable,
  104.     kStdOkItemIndex                = ok,
  105.     kStdCancelItemIndex            = cancel,
  106.     kStopIcon                    = stopIcon,
  107.     kNoteIcon                    = noteIcon,
  108.     kCautionIcon                = cautionIcon
  109. };
  110.  
  111. #if OLDROUTINENAMES
  112. enum {
  113.     kOkItemIndex                = kStdOkItemIndex,
  114.     kCancelItemIndex            = kStdCancelItemIndex
  115. };
  116.  
  117. #endif
  118. typedef SInt16 DITLMethod;
  119.  
  120.  
  121. enum {
  122.     overlayDITL                    = 0,
  123.     appendDITLRight                = 1,
  124.     appendDITLBottom            = 2
  125. };
  126.  
  127. typedef short StageList;
  128.  
  129. typedef OSType DialogPropertyTag;
  130.  
  131. #if STRICT_WINDOWS
  132. typedef struct OpaqueDialogRef *DialogPtr;
  133.  
  134. typedef struct OpaqueDialogRef *DialogRef;
  135.  
  136. #else
  137. typedef WindowPtr DialogPtr;
  138.  
  139. typedef DialogPtr DialogRef;
  140.  
  141. #endif
  142. typedef pascal void (*SoundProcPtr)(short soundNumber);
  143. typedef pascal Boolean (*ModalFilterProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short *itemHit);
  144. typedef pascal void (*UserItemProcPtr)(WindowPtr theWindow, short itemNo);
  145.  
  146. #if GENERATINGCFM
  147. typedef UniversalProcPtr SoundUPP;
  148. typedef UniversalProcPtr ModalFilterUPP;
  149. typedef UniversalProcPtr UserItemUPP;
  150. #else
  151. typedef SoundProcPtr SoundUPP;
  152. typedef ModalFilterProcPtr ModalFilterUPP;
  153. typedef UserItemProcPtr UserItemUPP;
  154. #endif
  155.  
  156. enum {
  157.     uppSoundProcInfo = kPascalStackBased
  158.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))),
  159.     uppModalFilterProcInfo = kPascalStackBased
  160.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  161.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  162.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord*)))
  163.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short*))),
  164.     uppUserItemProcInfo = kPascalStackBased
  165.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr)))
  166.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  167. };
  168.  
  169. #if GENERATINGCFM
  170. #define NewSoundProc(userRoutine)        \
  171.         (SoundUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSoundProcInfo, GetCurrentArchitecture())
  172. #define NewModalFilterProc(userRoutine)        \
  173.         (ModalFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppModalFilterProcInfo, GetCurrentArchitecture())
  174. #define NewUserItemProc(userRoutine)        \
  175.         (UserItemUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUserItemProcInfo, GetCurrentArchitecture())
  176. #else
  177. #define NewSoundProc(userRoutine)        \
  178.         ((SoundUPP) (userRoutine))
  179. #define NewModalFilterProc(userRoutine)        \
  180.         ((ModalFilterUPP) (userRoutine))
  181. #define NewUserItemProc(userRoutine)        \
  182.         ((UserItemUPP) (userRoutine))
  183. #endif
  184.  
  185. #if GENERATINGCFM
  186. #define CallSoundProc(userRoutine, soundNumber)        \
  187.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSoundProcInfo, (soundNumber))
  188. #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit)        \
  189.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppModalFilterProcInfo, (theDialog), (theEvent), (itemHit))
  190. #define CallUserItemProc(userRoutine, theWindow, itemNo)        \
  191.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppUserItemProcInfo, (theWindow), (itemNo))
  192. #else
  193. #define CallSoundProc(userRoutine, soundNumber)        \
  194.         (*(userRoutine))((soundNumber))
  195. #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit)        \
  196.         (*(userRoutine))((theDialog), (theEvent), (itemHit))
  197. #define CallUserItemProc(userRoutine, theWindow, itemNo)        \
  198.         (*(userRoutine))((theWindow), (itemNo))
  199. #endif
  200.  
  201. #if ! STRICT_WINDOWS
  202. struct DialogRecord {
  203.     WindowRecord                    window;
  204.     Handle                            items;
  205.     TEHandle                        textH;
  206.     short                            editField;
  207.     short                            editOpen;
  208.     short                            aDefItem;
  209. };
  210. typedef struct DialogRecord DialogRecord;
  211.  
  212. typedef DialogRecord *DialogPeek;
  213.  
  214. #endif
  215. struct DialogTemplate {
  216.     Rect                            boundsRect;
  217.     short                            procID;
  218.     Boolean                            visible;
  219.     Boolean                            filler1;
  220.     Boolean                            goAwayFlag;
  221.     Boolean                            filler2;
  222.     long                            refCon;
  223.     short                            itemsID;
  224.     Str255                            title;
  225. };
  226. typedef struct DialogTemplate DialogTemplate;
  227.  
  228. typedef DialogTemplate *DialogTPtr, **DialogTHndl;
  229.  
  230. struct AlertTemplate {
  231.     Rect                            boundsRect;
  232.     short                            itemsID;
  233.     StageList                        stages;
  234. };
  235. typedef struct AlertTemplate AlertTemplate;
  236.  
  237. typedef AlertTemplate *AlertTPtr, **AlertTHndl;
  238.  
  239. extern pascal void InitDialogs(void *ignored)
  240.  ONEWORDINLINE(0xA97B);
  241. extern pascal void ErrorSound(SoundUPP soundProc)
  242.  ONEWORDINLINE(0xA98C);
  243. extern pascal DialogRef NewDialog(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl)
  244.  ONEWORDINLINE(0xA97D);
  245. extern pascal DialogRef GetNewDialog(short dialogID, void *dStorage, WindowRef behind)
  246.  ONEWORDINLINE(0xA97C);
  247. extern pascal void CloseDialog(DialogRef theDialog)
  248.  ONEWORDINLINE(0xA982);
  249. extern pascal void DisposeDialog(DialogRef theDialog)
  250.  ONEWORDINLINE(0xA983);
  251. extern pascal void ParamText(ConstStr255Param param0, ConstStr255Param param1, ConstStr255Param param2, ConstStr255Param param3)
  252.  ONEWORDINLINE(0xA98B);
  253. extern pascal void ModalDialog(ModalFilterUPP modalFilter, short *itemHit)
  254.  ONEWORDINLINE(0xA991);
  255. extern pascal Boolean IsDialogEvent(const EventRecord *theEvent)
  256.  ONEWORDINLINE(0xA97F);
  257. extern pascal Boolean DialogSelect(const EventRecord *theEvent, DialogRef *theDialog, short *itemHit)
  258.  ONEWORDINLINE(0xA980);
  259. extern pascal void DrawDialog(DialogRef theDialog)
  260.  ONEWORDINLINE(0xA981);
  261. extern pascal void UpdateDialog(DialogRef theDialog, RgnHandle updateRgn)
  262.  ONEWORDINLINE(0xA978);
  263. extern pascal short Alert(short alertID, ModalFilterUPP modalFilter)
  264.  ONEWORDINLINE(0xA985);
  265. extern pascal short StopAlert(short alertID, ModalFilterUPP modalFilter)
  266.  ONEWORDINLINE(0xA986);
  267. extern pascal short NoteAlert(short alertID, ModalFilterUPP modalFilter)
  268.  ONEWORDINLINE(0xA987);
  269. extern pascal short CautionAlert(short alertID, ModalFilterUPP modalFilter)
  270.  ONEWORDINLINE(0xA988);
  271. extern pascal void GetDialogItem(DialogRef theDialog, short itemNo, short *itemType, Handle *item, Rect *box)
  272.  ONEWORDINLINE(0xA98D);
  273. extern pascal void SetDialogItem(DialogRef theDialog, short itemNo, short itemType, Handle item, const Rect *box)
  274.  ONEWORDINLINE(0xA98E);
  275. extern pascal void HideDialogItem(DialogRef theDialog, short itemNo)
  276.  ONEWORDINLINE(0xA827);
  277. extern pascal void ShowDialogItem(DialogRef theDialog, short itemNo)
  278.  ONEWORDINLINE(0xA828);
  279. extern pascal void SelectDialogItemText(DialogRef theDialog, short itemNo, short strtSel, short endSel)
  280.  ONEWORDINLINE(0xA97E);
  281. extern pascal void GetDialogItemText(Handle item, Str255 text)
  282.  ONEWORDINLINE(0xA990);
  283. extern pascal void SetDialogItemText(Handle item, ConstStr255Param text)
  284.  ONEWORDINLINE(0xA98F);
  285. extern pascal short FindDialogItem(DialogRef theDialog, Point thePt)
  286.  ONEWORDINLINE(0xA984);
  287. extern pascal DialogRef NewColorDialog(void *dStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle items)
  288.  ONEWORDINLINE(0xAA4B);
  289. extern pascal short GetAlertStage( void )
  290.     TWOWORDINLINE( 0x3EB8, 0x0A9A ); /* MOVE.w $0A9A,(SP) */
  291. extern DialogRef newdialog(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl);
  292. extern DialogRef newcolordialog(void *dStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle items);
  293. extern pascal void ResetAlertStage(void)
  294.  TWOWORDINLINE(0x4278, 0x0A9A);
  295. extern pascal void DialogCut(DialogRef theDialog);
  296. extern pascal void DialogPaste(DialogRef theDialog);
  297. extern pascal void DialogCopy(DialogRef theDialog);
  298. extern pascal void DialogDelete(DialogRef theDialog);
  299. extern pascal void SetDialogFont( short value )
  300.     TWOWORDINLINE( 0x31DF, 0x0AFA ); /* MOVE.w (SP)+,$0AFA */
  301. #if CGLUESUPPORTED
  302. extern void paramtext(const char *param0, const char *param1, const char *param2, const char *param3);
  303. extern void getdialogitemtext(Handle item, char *text);
  304. extern void setdialogitemtext(Handle item, const char *text);
  305. extern short finddialogitem(DialogRef theDialog, Point *thePt);
  306. #endif
  307. extern pascal void AppendDITL(DialogRef theDialog, Handle theHandle, DITLMethod method);
  308. extern pascal short CountDITL(DialogRef theDialog);
  309. extern pascal void ShortenDITL(DialogRef theDialog, short numberItems);
  310. extern pascal Boolean StdFilterProc(DialogRef theDialog, EventRecord *event, short *itemHit);
  311. extern pascal OSErr GetStdFilterProc(ModalFilterUPP *theProc)
  312.  THREEWORDINLINE(0x303C, 0x0203, 0xAA68);
  313. extern pascal OSErr SetDialogDefaultItem(DialogRef theDialog, short newItem)
  314.  THREEWORDINLINE(0x303C, 0x0304, 0xAA68);
  315. extern pascal OSErr SetDialogCancelItem(DialogRef theDialog, short newItem)
  316.  THREEWORDINLINE(0x303C, 0x0305, 0xAA68);
  317. extern pascal OSErr SetDialogTracksCursor(DialogRef theDialog, Boolean tracks)
  318.  THREEWORDINLINE(0x303C, 0x0306, 0xAA68);
  319. #if OLDROUTINENAMES
  320. #if !GENERATINGCFM
  321. extern pascal void CouldDialog(short dialogID)
  322.  ONEWORDINLINE(0xA979);
  323. extern pascal void FreeDialog(short dialogID)
  324.  ONEWORDINLINE(0xA97A);
  325. extern pascal void CouldAlert(short alertID)
  326.  ONEWORDINLINE(0xA989);
  327. extern pascal void FreeAlert(short alertID)
  328.  ONEWORDINLINE(0xA98A);
  329. #endif
  330. #define DisposDialog(theDialog) DisposeDialog(theDialog)
  331. #define UpdtDialog(theDialog, updateRgn) UpdateDialog(theDialog, updateRgn)
  332. #define GetDItem(theDialog, itemNo, itemType, item, box)  \
  333.     GetDialogItem(theDialog, itemNo, itemType, item, box)
  334. #define SetDItem(theDialog, itemNo, itemType, item, box)  \
  335.     SetDialogItem(theDialog, itemNo, itemType, item, box)
  336. #define HideDItem(theDialog, itemNo) HideDialogItem(theDialog, itemNo)
  337. #define ShowDItem(theDialog, itemNo) ShowDialogItem(theDialog, itemNo)
  338. #define SelIText(theDialog, itemNo, strtSel, endSel)  \
  339.     SelectDialogItemText(theDialog, itemNo, strtSel, endSel)
  340. #define GetIText(item, text) GetDialogItemText(item, text)
  341. #define SetIText(item, text) SetDialogItemText(item, text)
  342. #define FindDItem(theDialog, thePt) FindDialogItem(theDialog, thePt)
  343. #define NewCDialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)  \
  344.     NewColorDialog(dStorage, boundsRect, title, visible, procID, behind,  \
  345.     goAwayFlag, refCon, items)
  346. #define GetAlrtStage() GetAlertStage()
  347. #define ResetAlrtStage() ResetAlertStage()
  348. #define DlgCut(theDialog) DialogCut(theDialog)
  349. #define DlgPaste(theDialog) DialogPaste(theDialog)
  350. #define DlgCopy(theDialog) DialogCopy(theDialog)
  351. #define DlgDelete(theDialog) DialogDelete(theDialog)
  352. #define SetDAFont(fontNum) SetDialogFont(fontNum)
  353. #if CGLUESUPPORTED
  354. #define newcdialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)  \
  355.     newcolordialog(dStorage, boundsRect, title, visible, procID, behind,  \
  356.     goAwayFlag, refCon, items)
  357. #define getitext(item, text) getdialogitemtext(item, text)
  358. #define setitext(item, text) setdialogitemtext(item, text)
  359. #define findditem(theDialog, thePt) finddialogitem(theDialog, thePt)
  360. #endif
  361. #else
  362. #endif
  363. /*####################################################################################
  364.  
  365.      Dialog Accessors
  366.  
  367.     Use these with or without STRICT_WINDOWS and your source will more easily migrate
  368.     to being Copland-savvy.  When STRICT_WINDOWS is set to true, the DialogRecord and
  369.     DialogPeek are no longer defined.  This will allow you to, from a source code level, 
  370.     remove all direct accesses to Dialog Manager data structures.
  371.  
  372.     These accessors will be available as true API entrypoints in Copland.
  373.  
  374.     If you don't see an accessor for a field you need, there's probably a very good
  375.     reason.  Needing access to fields for which there is no accessor is a good indicator
  376.     of behavior that is not Copland-savvy.  Such behavior does not necessarily make your 
  377.     code incompatible, but it likely something we are trying to discourage as we evolve
  378.     the toolbox into a more robust and useful service.
  379.  
  380.     Please direct all questions regarding usage to the TOOLBOX AppleLink address.
  381.  
  382. #####################################################################################*/
  383. #ifdef __cplusplus
  384. inline WindowRef     GetDialogWindow(DialogRef dialog)        { return (WindowRef) dialog;                         }
  385. inline SInt16        GetDialogDefaultItem(DialogRef dialog)  { return (*(SInt16 *) (((UInt8 *) dialog) + 168));    }
  386. inline SInt16        GetDialogCancelItem(DialogRef dialog)     { return (*(SInt16 *) (((UInt8 *) dialog) + 166));    }
  387. inline SInt16        GetDialogKeyboardFocusItem(DialogRef dialog)    { return ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ? -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1); }
  388. inline void        SetGrafPortOfDialog(DialogRef dialog) { SetPort ((GrafPtr) dialog); }
  389. #else
  390. #define GetDialogWindow(dialog)    ((WindowRef) dialog)
  391. #define GetDialogDefaultItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 168))
  392. #define GetDialogCancelItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 166))
  393. #define GetDialogKeyboardFocusItem(dialog) ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ? -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1)
  394. #define SetGrafPortOfDialog(dialog) do { SetPort ((GrafPtr) dialog); } while (false);
  395. #endif
  396.  
  397. #if PRAGMA_IMPORT_SUPPORTED
  398. #pragma import off
  399. #endif
  400.  
  401. #if PRAGMA_ALIGN_SUPPORTED
  402. #pragma options align=reset
  403. #endif
  404.  
  405. #ifdef __cplusplus
  406. }
  407. #endif
  408.  
  409. #endif /* __DIALOGS__ */
  410.